package leetcode.code;

import leetcode.IDebug;
import leetcode.helper.HelpDebug;
import leetcode.helper.MaxDebug;

public class Solution12 implements IDebug {

	private String[] num1 = new String[] { "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX" };
	private String[] num10 = new String[] { "", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC" };
	private String[] num100 = new String[] { "", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM" };
	private String[] num1000 = new String[] { "", "M", "MM", "MMM", "", "", "", "", "", "" };
	private String[][] nums = new String[][] { num1000, num100, num10, num1 };
	private int[] pos = new int[] { 1000, 100, 10, 1 };

	public String intToRoman(int num) {
		StringBuffer ans = new StringBuffer();
		for (int i = 0; i < 4; i++) {
			int number = num / pos[i];
			if (number != 0) {
				ans.append(nums[i][number]);
			}
			num %= pos[i];
		}
		return ans.toString();
	}

	@Override
	public void debug1() {
		int num = 1994;
		String e = "MCMXCIV";
		String r = this.intToRoman(num);
		HelpDebug.compare(e, r);
	}

	@Override
	public void debug2() {
		int num = 3944;
		String e = "MMMCMXLIV";
		String r = this.intToRoman(num);
		HelpDebug.compare(e, r);
	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution12 so = new Solution12();
		MaxDebug.debug14(so);
	}

}
